salt-minion:
  cmd.run:
{% if grains['osfinger'] == 'CentOS-6' %}
    - name: rpm -ivh https://repo.saltstack.com/yum/redhat/salt-repo-2016.11-2.el6.noarch.rpm
{% elif grains['osfinger'] == 'CentOS-7' %}
    - name: rpm -ivh https://repo.saltstack.com/yum/redhat/salt-repo-2016.11-2.el7.noarch.rpm
{% endif %}
    - unless: rpm -qa | grep salt-minion
  pkg:
    - installed
    - require:
      - cmd: salt-minion
  file.managed:
    - name: /etc/salt/minion
    - source: salt://salt-minion/minion
    - template: jinja
    - backup: minion.bak
    - defaults:
      master: {{ pillar['master'] }}
      id: {{ grains['fqdn'] }}
    - require:
      - pkg: salt-minion
  service.running:
    - enable: True
    - watch:
      - file: /etc/salt/minion
